import time
import json
from threading import Lock
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
def get_cookie():
    service = Service(executable_path='D:\chromedriver_win32 (1)\chromedriver.exe')
    driver = webdriver.Chrome(service=service)
    url = 'https://www.gaokao.cn/'
    driver.get(url)
    time.sleep(30)
    dictCookies = driver.get_cookies()
    jsonCookies = json.dumps(dictCookies)
    print(jsonCookies)

    with open("cookies_juejin.json", "w") as fp:
        fp.write(jsonCookies)
    # 关闭浏览器
    driver.quit()

if __name__ == '__main__':
    get_cookie()